//
//	jQuery Validate example script
//
//	Prepared by David Cochran
//
//	Free for your use -- No warranties, no guarantees!
//


$(document).ready(function(){

	// Validate
	// http://bassistance.de/jquery-plugins/jquery-plugin-validation/
	// http://docs.jquery.com/Plugins/Validation/
	// http://docs.jquery.com/Plugins/Validation/validate#toptions
		$('#connexion-form').validate({
			rules: {
				nameConn: {
					minlength : 2,
					required: true
				},
				pwdConn: {
					minlength : 5,
					required: true
				}
			}
		});

		$('#contact-form').validate({
	    rules: {
	      name: {
	        minlength: 2,
	        required: true
	      },
	      email: {
	        required: true,
	        email: true
	      },
	      age: {
	      	minlength: 2,
			digits: true,
	        required: true
	      },
	      password: {
			minlength: 5,
	        required: true
	      },
		  cpassword: {
			minlength: 5,
			required: true,
			equalTo: "#password"
		  }
	    },
			highlight: function(element) {
				$(element).closest('.control-group').removeClass('success').addClass('error');
			},
			success: function(element) {
				element
				.text('OK!').addClass('valid')
				.closest('.control-group').removeClass('error').addClass('success');
			}
	  });

}); // end document.ready